package com.atung.merchant.controller;

import com.atung.merchant.dto.OrderInfoEntity;
import com.atung.merchant.result.ApiResult;
import com.atung.merchant.service.OrderService;
import com.atung.merchant.vo.*;
import com.atung.merchant.vo.save.SaveOrderRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/api/order")
@Api(tags = "订单管理")
public class OrderController {
    @Resource
    private OrderService orderService;
    @PostMapping("/details")
    @ApiOperation("订单详情")
    public ApiResult<OrderDetailsResponse> queryOrderDetails(@RequestBody IdRequest request) {
        OrderDetailsResponse orderDetailsResponse =orderService.queryOrderDetailsService(request);
        return ApiResult.ok(orderDetailsResponse);
    }
    @PostMapping()
    @ApiOperation("新增订单")
    public ApiResult<OrderInfoEntity> saveOrder(@RequestBody SaveOrderRequest request) {
        OrderInfoEntity roomInfoEntity =orderService.saveOrderService(request);
        return ApiResult.ok(roomInfoEntity);
    }
    @PostMapping("/cancel")
    @ApiOperation("取消订单")
    public ApiResult<OrderInfoEntity> cancelOrder(@RequestBody @Valid IdRequest request) {
        return   orderService.cancelOrderService(request);
    }
    @PostMapping("/settlement")
    @ApiOperation("结算订单")
    public ApiResult settlementOrder(@RequestBody  @Valid IdRequest request) {
        return orderService.settlementOrderService(request);
    }
}
